package com.yu.learn.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

/**
 * @author yushijun
 * @date 2018/5/7
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Value("${spring.application.name}")
    private String application;

    @ResponseBody
    @RequestMapping(value = "/nginx", method = RequestMethod.GET)
    public String test(HttpServletRequest request) {

        request.getServerName();
        request.getServerPort();
        log.error("接收到请求：{}",request.getRemoteAddr()+ "ip " + request.getServerName() + "：" + request.getServerPort() + application);
        return request.getRemoteAddr()+ "ip " + request.getServerName() + "：" + request.getServerPort() + application;

    }

}
